/*
 * @Author: sy
 * @Date: 2021-08-17 14:55:54
 * @LastEditTime: 2022-08-22 20:41:11
 * @Description: file content
 */

import * as CryptoJS from 'crypto-js';

const DecodeBase64 = (data)=>{
  data = CryptoJS.enc.Base64.parse(data);
  return data.toString(CryptoJS.enc.Utf8);
}

const evnConfig = {
  isMock: false,
  environment: 2 // 0：表示正式环境，1：表示演示环境，2：表示测试环境，3：开发环境
}

const appInfo = {
  _appname: 'ddmg_financial',
  _appentrance: 'ddmg_financial_PC',
  _appversion: 'v1.0'
}

const getConfig = () => {
  const apiurl = DecodeBase64(window.ddmgConfig.hhl);
  const host = DecodeBase64(window.ddmgConfig.hht);
  const caller = DecodeBase64(window.ddmgConfig.hhr);
  const callee = DecodeBase64(window.ddmgConfig.hhe);
  const config = {
    ...window.ddmgConfig,
    apiurl: "https://"+apiurl,
    host: host,
    caller: caller,
    callee: callee,
  };
  delete config.hhl;
  delete config.hht;
  delete config.hhr;
  delete config.hhe;
  return config;
}

const ddmgConfig = getConfig() // window.ddmgConfig[evnConfig.environment]

export { appInfo, ddmgConfig, evnConfig }
